package com.example.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.example.config.ResponseVO;
import com.example.pojo.ClassAlbum;
import com.example.service.ClassAlbumService;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

@RestController
@RequestMapping("/classesAlbum")
public class ClassAlbumController {
    @Resource
    private ClassAlbumService classAlbumService;

    // 查询班级相册内容
    @GetMapping("/getClassesAlbumList/{classId}")
    public ResponseEntity<ResponseVO<List<ClassAlbum>>> getClassesAlbumList(@PathVariable Long classId){
        return classAlbumService.getClassesAlbumList(classId);
    }

    @GetMapping("/getClassesAlbumPage/{classId}")
    public ResponseEntity<ResponseVO<IPage<ClassAlbum>>> getClassesAlbumPage(@PathVariable Long classId) {
        return classAlbumService.getClassesAlbumPage(1,5,classId);
    }

    @PostMapping("/addOrUpdateClassAlbum")
    public ResponseEntity<ResponseVO<String>> addOrUpdateClassAlbum(@RequestBody ClassAlbum classAlbum){
        System.out.println(classAlbum);
        return classAlbumService.addOrUpdateClassAlbum(classAlbum);
    }
}
